<?php include "classes.inc" ?>
<?php include "constants.inc" ?>
<?php if (!session_id()) session_start(); ?>   
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<?
    $activeTabIndex = 1; // default tab is news page
    
    function leftCorner($index) {
        return ($GLOBALS['activeTabIndex'] == $index) ? "re_FFFFFF_l.gif" : "re_99CCFF_l.gif";
    }
    
    function rightCorner($index) {
        return ($GLOBALS['activeTabIndex'] == $index) ? "re_FFFFFF_r.gif" : "re_99CCFF_r.gif";
    }
    
    function spacerClass($index) {
        return ($GLOBALS['activeTabIndex'] == $index) ? "activeSpacer" : "inactiveSpacer";
    }
    
    function setTabIndex($index) {
        $GLOBALS['activeTabIndex'] = $index;
    }
    
    function createPage($title) {
?>
<head>
<title><?=$title?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="/assets/css/default.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="/assets/js/ajax.js"></script>
</head>
<?        
        createBody("default");
    }

    function createBody($style) {
?>
<body bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0" class="<?=$style?>">

<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td>
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="7">
                        <img src="/assets/images/spacer.gif" height="1" width="7" ALT="">
                    </td>
                    <td width="150" align="left"><img src="/assets/images/headerbar_kerst.gif" alt="" ></td>
                </tr>
                <tr>
                    <td colspan="2" height="12">
                        <img src="/assets/images/spacer.gif" alt="" height="12" width="1">
                    </td>
                </tr>
            </table>
        </td>
        <td align="right" valign="top">
            <br/>
        <?php
          $conn = mysql_connect(DB_SERVER, DB_USER, DB_PWD);
          mysql_select_db(DB_CATALOG);

          $user = null;
          if ( isset($_SESSION['user']) ) {
                  $user = $_SESSION['user'];
        ?>
            <a href="/logout.php?redirect=/newsbox.php"><img src="/assets/images/24x24/plain/exit.gif" border="0" alt="Log uit"></a>
            <br>&nbsp;<br>
            <span class="headerSmall">User <?=$_SESSION['user']->name?> logged in at <?=$user->login_date?>.</span>
            

        <?php
            } else {
                if ( isset($_POST['username']) && isset($_POST['password']) ) {
                    $username = $_POST['username'];
                    $password = $_POST['password'];

                    $query = sprintf("SELECT u.user_id, club_id, upload FROM user u
                    LEFT JOIN user_rights ur on u.user_id = ur.user_id
                    where username = '%s'
                    AND password = '%s'", mysql_real_escape_string($username),
                    mysql_real_escape_string($password));
                    $result = mysql_query($query);
                    $num_rows = mysql_num_rows($result);

                    if ($num_rows == 1) {
                        $user = new User($username);
                        $row = mysql_fetch_assoc($result);
                        $user->user_id = $row['user_id'];
                        $user->club_id = $row['club_id'];
                        $user->can_upload = $row['upload'];
                        $_SESSION['user'] = $user;
        ?>
                        <a href="/logout.php?redirect=/newsbox.php"><img src="/assets/images/24x24/plain/exit.gif" border="0" alt="Log uit"></a>
                        <br>&nbsp;<br>
                        <span class="headerSmall">User <?=$_SESSION['user']->name?> logged in at <?=$user->login_date?>.</span>
        <?
                    } else {
        ?>
            <span class="headerSmall" style="color:#FFFFCC">Gebruikersnaam '<?=$username?>' en/of paswoord ongeldig, probeer opnieuw.</span>
            <form name="login" action="" method="post" class="login">
                <input id="username" name="username" type="text" size="20" value="gebruikersnaam"
                    onFocus="javascript:document.getElementById('username').value=''" />
                <input id="password" name="password" type="password" size="20" value="paswoord"
                    onFocus="javascript:document.getElementById('password').value=''" />
                <input type="submit" value="inloggen" />
                
            </form>
            
        <?php
                    }

                    mysql_free_result($result);

                } else {
        ?>
                    <form name="login" action="" method="post" class="login">
                        <input id="username" name="username" type="text" size="20" value="gebruikersnaam"
                            onFocus="javascript:document.getElementById('username').value=''" />
                        <input id="password" name="password" type="password" size="20" value="paswoord"
                            onFocus="javascript:document.getElementById('password').value=''" />
                        <input type="submit" value="inloggen" />
                        
                    </form>
                    
        <?php
                }
            }
        ?>
            
        </td>
        <td>&nbsp;</td>
    </tr>
    
</table>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td align="left">
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td rowspan="2" width="7"><img src="/assets/images/spacer.gif" alt="" height="1" width="7"></td>
                    <td valign="top"><img src="/assets/images/tabcorners/<?=leftCorner(1)?>" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="<?=spacerClass(1)?>"><img src="/assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/newsbox.php" target="_top"><span class="tabName">Nieuwsbox</span></a></td>
                    <td valign="top"><img src="/assets/images/tabcorners/<?=rightCorner(1)?>" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="/assets/images/spacer.gif" alt="" height="1" width="2"></td>
                    
                    <td valign="top"><img src="/assets/images/tabcorners/<?=leftCorner(2)?>" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="<?=spacerClass(2)?>"><img src="/assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/tornooien/tornooien.php" target="_top"><span class="tabName">Tornooien</span></a></td>
                    <td valign="top"><img src="/assets/images/tabcorners/<?=rightCorner(2)?>" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="/assets/images/spacer.gif" alt="" height="1" width="2"></td>

                    <td valign="top"><img src="/assets/images/tabcorners/<?=leftCorner(3)?>" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="<?=spacerClass(3)?>"><img src="/assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/bestuur/bestuur.php" target="_top"><span class="tabName">Bestuur</span></a></td>
                    <td valign="top"><img src="/assets/images/tabcorners/<?=rightCorner(3)?>" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="/assets/images/spacer.gif" alt="" height="1" width="2"></td>

                    <td valign="top"><img src="/assets/images/tabcorners/<?=leftCorner(4)?>" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="<?=spacerClass(4)?>"><img src="/assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/advalvas/index.html" target="_top"><span class="tabName">Ad Valvas</span></a></td>
                    <td valign="top"><img src="/assets/images/tabcorners/<?=rightCorner(4)?>" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="/assets/images/spacer.gif" alt="" height="1" width="2"></td>

                    <td valign="top"><img src="/assets/images/tabcorners/<?=leftCorner(5)?>" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="<?=spacerClass(5)?>"><img src="/assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="http://www.frbe-kbsb.be/GestionFICHES/FRBE_Fiche.php" target="_blank"><span class="tabName">ELO</span></a></td>
                    <td valign="top"><img src="/assets/images/tabcorners/<?=rightCorner(5)?>" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="/assets/images/spacer.gif" alt="" height="1" width="2"></td>

                    <td valign="top"><img src="/assets/images/tabcorners/<?=leftCorner(6)?>" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="<?=spacerClass(6)?>"><img src="/assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/clubs/clubs.php" target="_top"><span class="tabName">Clubs</span></a></td>
                    <td valign="top"><img src="/assets/images/tabcorners/<?=rightCorner(6)?>" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="/assets/images/spacer.gif" alt="" height="1" width="2"></td>

                    <td valign="top"><img src="/assets/images/tabcorners/<?=leftCorner(7)?>" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="<?=spacerClass(7)?>"><img src="/assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/jeugd/jeugd.php" target="_top"><span class="tabName">Jeugd</span></a></td>
                    <td valign="top"><img src="/assets/images/tabcorners/<?=rightCorner(7)?>" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="/assets/images/spacer.gif" alt="" height="1" width="2"></td>

                    <td valign="top"><img src="/assets/images/tabcorners/<?=leftCorner(8)?>" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="<?=spacerClass(8)?>"><img src="/assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/links/index.php" target="_top"><span class="tabName">Links</span></a></td>
                    <td valign="top"><img src="/assets/images/tabcorners/<?=rightCorner(8)?>" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="/assets/images/spacer.gif" alt="" height="1" width="2"></td>
                    
                    <td valign="top"><img src="/assets/images/tabcorners/<?=leftCorner(9)?>" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="<?=spacerClass(9)?>"><img src="/assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/wiki" target="_blank"><span class="tabName">Wiki</span></a></td>
                    <td valign="top"><img src="/assets/images/tabcorners/<?=rightCorner(9)?>" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="/assets/images/spacer.gif" alt="" height="1" width="2"></td>
                    
                    <td valign="top"><img src="/assets/images/tabcorners/<?=leftCorner(10)?>" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="<?=spacerClass(10)?>"><img src="/assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/poll/survey.php"><span class="tabName">Poll's</span></a></td>
                    <td valign="top"><img src="/assets/images/tabcorners/<?=rightCorner(10)?>" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="/assets/images/spacer.gif" alt="" height="1" width="2"></td>
                    
                    <!--
                    <td valign="top"><img src="/assets/images/tabcorners/<?=leftCorner(10)?>" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="<?=spacerClass(10)?>"><img src="/assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/kalender/kalender.php" target="_blank"><span class="tabName">Kalender</span></a></td>
                    <td valign="top"><img src="/assets/images/tabcorners/<?=rightCorner(10)?>" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="/assets/images/spacer.gif" alt="" height="1" width="2"></td>
                    -->
                </tr>
                <tr>
                    <td class="<?=spacerClass(1)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    <td class="<?=spacerClass(1)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    <td class="<?=spacerClass(2)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    <td class="<?=spacerClass(2)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    <td class="<?=spacerClass(3)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    <td class="<?=spacerClass(3)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    <td class="<?=spacerClass(4)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    <td class="<?=spacerClass(4)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    <td class="<?=spacerClass(5)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    <td class="<?=spacerClass(5)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    <td class="<?=spacerClass(6)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    <td class="<?=spacerClass(6)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    <td class="<?=spacerClass(7)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    <td class="<?=spacerClass(7)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    <td class="<?=spacerClass(8)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    <td class="<?=spacerClass(8)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    <td class="<?=spacerClass(9)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    <td class="<?=spacerClass(9)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    
                    <td class="<?=spacerClass(10)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    <td class="<?=spacerClass(10)?>"><img src="/assets/images/spacer.gif" alt=""></td>
                    
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td width="100%" bgcolor="#FFFFFF" colspan="13"><img border="0" width="30" src="/assets/images/FFFFFF.gif" height="12" alt=""></td>
    </tr>
</table>
<?
    }
?>